var editIndex = undefined;
var type; // 当前字段类型选择选择的值

var templateId = "";









function cancel() {

    parent.reportManager.reLoadReportTreeRoot();
    parent.reportManager.reLoadReportTree();

    parent.$('#' + _dialogId).dialog('close');

}


/**
 * 获取url参数（主要解决iframe传递参数）
 */
function getUrlParam(src, key) {
    if (src.lastIndexOf("?") != -1) {
        var queryStr = src.substring(src.lastIndexOf("?") + 1, src.length);
        if (!key) {
            return queryStr; // 返回所有参数
        } else {
            var params = queryStr.split("&");
            for (var j = 0; j < params.length; j++) {
                var tmp = params[j].split("=");
                if (tmp[0] == key) {
                    return tmp[1];
                    break;
                }
            }
        }
    }
}
/**
 * 用于单元格编辑是重写的方法
 */
$.extend($.fn.datagrid.methods, {
    editCell: function(jq, param) {
        return jq.each(function() {
            var fields = $(this).datagrid('getColumnFields', true).concat(
                $(this).datagrid('getColumnFields'));
            for (var i = 0; i < fields.length; i++) {
                var col = $(this).datagrid('getColumnOption', fields[i]);
                col.editor1 = col.editor;
                if (fields[i] != param.field) {
                    var fieldOpts = $(this).datagrid('getColumnOption',
                        fields[i]);
                    if (!fieldOpts.hidden || fieldOpts.hidden == false) {
                        col.editor = null;
                    }
                }
            }
            $(this).datagrid('beginEdit', param.index);
            for (var i = 0; i < fields.length; i++) {
                var col = $(this).datagrid('getColumnOption', fields[i]);
                col.editor = col.editor1;
            }
        });
    },
    addEditor: function(jq, param) {
        if (param instanceof Array) {
            $.each(param, function(index, item) {
                var e = $(jq).datagrid('getColumnOption', item.field);
                e.editor = item.editor;
            });
        } else {
            var e = $(jq).datagrid('getColumnOption', param.field);
            e.editor = param.editor;
        }
    },
    removeEditor: function(jq, param) {
        if (param instanceof Array) {
            $.each(param, function(index, item) {
                var e = $(jq).datagrid('getColumnOption', item);
                e.editor = {};
            });
        } else {
            var e = $(jq).datagrid('getColumnOption', param);
            e.editor = {};
        }
    }
});
/**
 * 单元格点击事件
 *
 * @param index
 * @param field
 * @param value
 * commonLang.tip.alert,提示
 * commonLang.tip.notAllow 该表已经存在数据，不允许修改此列！
 */
function onClickCell(index, field, value) {
    var rowDataNew = $('#cbbTabColumnsDataGrid').datagrid('getData').rows[index]; // 当前行
    //var isSysCol = "N";// 是否系统初始化字段,默认否
    var isNewNew = "";
    if (rowDataNew != undefined) {
        isNewNew = rowDataNew.isNew;
        //isSysCol = rowDataNew.colIsSys;
    }
    // 验证点击之前的行
    if (editIndex == index || endEditing()) {
        $('#cbbTabColumnsDataGrid').datagrid('endEdit', editIndex);
        if (isNewNew == "Y") { // 新增行
            if (field == 'COLLABEL') {
                changeName(editIndex, index, field);
            }
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', index).datagrid(
                'editCell', {
                    index: index,
                    field: field
                });
        } else { // 加载行
            if (field == 'COLLABEL') {
                $('#cbbTabColumnsDataGrid')
                    .datagrid('selectRow', index).datagrid(
                    'editCell', {
                        index: index,
                        field: field
                    });
            } else if (field == 'COLNAME' || field == 'COLTYPE' || field == 'COLLENGTH' || field == 'COLDECIMAL') {
                $.messager.alert(commonLang.tip.alert,commonLang.tip.notAllow,'warning');
                editIndex = index;
                return false;
            }
        }
    }
    editIndex = index;

}


/**
 * 根据中文名称改变英文名称
 *
 * @param index
 */
function changeName(editIndex, index, field) {
    $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex).datagrid(
        'beginEdit', editIndex);
    // 定义事件
    var editors = $('#cbbTabColumnsDataGrid').datagrid('getEditors', editIndex);
    var sfgzEditor = editors[0];
    sfgzEditor.target.bind('change', function() {
        var value = sfgzEditor.target.val();
        // 请求后台，转换字段名称
        $.ajax({
            url: 'platform/aos/commtempletmanagerController/onChangeCol',
            data: {
                name: value
            },
            type: 'post',
            dataType: 'json',
            success: function(result) {
                var editors = $('#cbbTabColumnsDataGrid').datagrid(
                    'getEditors', editIndex);
                var sfgzEditor = editors[1];
                sfgzEditor.target.val(result.textpinyin);
            }
        });
    });
    $('#cbbTabColumnsDataGrid').datagrid('endEdit', editIndex);

    $('#cbbTabColumnsDataGrid').datagrid('selectRow', index).datagrid(
        'editCell', {
            index: index,
            field: field
        });
    editIndex = index;
}



/**
 * 编辑数据
 * @param
 * commonLang.tip.alert 提示'
 * commonLang.tip.No,第
 * commonLang.tip.fieldNotNull 行【字段中文名】不能为空！
 * fieldnotlawful行【字段名】输入非法，请查证！
 * choosefieldtype 行，因为选择的【字段类型】为“
 * lengthbigger ”，因此【长度】的值不能超过4000！
 * lengthbigger1 ”，因此【长度】的值不能超过16！
 * decimalbigger ”，因此【小数位数】的值不能超过6！
 * decimalmustnull ”，因此【小数位数】的值必须为空！
 * lengthmustnull ”，因此【长度】的值必须为空！
 * checkdatacorrect 请检查数据是否正确！
 *
 */
function endEditing() {
    if (editIndex == undefined) {
        return true;
    }

    if ($('#cbbTabColumnsDataGrid').datagrid('validateRow', editIndex)) {

        $('#cbbTabColumnsDataGrid').datagrid('endEdit', editIndex);
        var rowData = $('#cbbTabColumnsDataGrid').datagrid('getData').rows[editIndex];
        if (rowData == undefined) {
            return true;
        }
        var colLabel = rowData.COLLABEL;
        if (colLabel == "" || colLabel == undefined) {
            $.messager.show({
                title: commonLang.tip.alert,
                msg: commonLang.tip.No + (editIndex + 1) + commonLang.tip.fieldNotNull,
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLABEL'
                });
            return false;
        }

        var colName = rowData.COLNAME;
        var regn = /^(?![0-9])\w+$/; // 字段名正则（包含字母数字下划线，不能已数字开头，20位）
        if (colName == "" || colName == undefined || !regn.test(colName)) {
            $.messager.show({
                title: commonLang.tip.alert,
                msg: No + (editIndex + 1) + commonLang.tip.fieldNotLawful,
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLNAME'
                });
            return false;
        }
        var colType = rowData.COLTYPE; // 字段类型
        var colTypeValue = "";
        if (colType == 'string') {
            colTypeValue = "字符串";
        } else if (colType == 'integer') {
            colTypeValue = "整型";
        } else if (colType == 'date') {
            colTypeValue = "日期时间型";
        } else if (colType == 'float') {
            colTypeValue = "浮点型";
        } else if (colType == 'blob') {
            colTypeValue = "BLOB";
        } else if (colType == 'clob') {
            colTypeValue = "CLOB";
        }
        var colLength = rowData.COLLENGTH; // 长度
        var colDecimal = rowData.COLDECIMAL; // 小数位数

        if (colType == "string" && colLength > 4000) { // 验证长度
            $.messager.show({
                title: commonLang.tip.alert,
                msg: No + (editIndex + 1) + commonLang.tip.chooseFieldType + colTypeValue + commonLang.tip.lengthBigger,
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLENGTH'
                });
            return false;
        }
        if ((colType == "integer" || colType == "float") && colLength > 16) { // 验证长度
            $.messager.show({
                title: commonLang.tip.alert,
                msg: No + (editIndex + 1) + commonLang.tip.chooseFieldType + colTypeValue + commonLang.tip.lengthBigger1,
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLENGTH'
                });
            return false;
        }
        if (colType == "float" && colDecimal > 6) { // 验证小数位数
            $.messager.show({
                title: commonLang.tip.alert,
                msg: No + (editIndex + 1) + commonLang.tip.chooseFieldType + colTypeValue + commonLang.tip.decimalBigger,
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLDECIMAL'
                });
            return false;
        }

        if ((colType == "string" || colType == "date" || colType == "clob" || colType == "integer" || colType == "blob") && colDecimal != "" && colDecimal != undefined) { // 验证小数位数
            $.messager.show({
                title: commonLang.tip.alert,
                msg: No + (editIndex + 1) + commonLang.tip.chooseFieldType + colTypeValue + commonLang.tip.decimalMustNull,
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLDECIMAL'
                });
            return false;
        }
        if ((colType == "date" || colType == "clob" || colType == "blob") && colLength != "" && colLength != undefined) { // 验证长度
            $.messager.show({
                title: commonLang.tip.alert,
                msg: No + (editIndex + 1) + commonLang.tip.chooseFieldType + colTypeValue + commonLang.tip.lengthMustNull,
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLENGTH'
                });
            return false;
        }
        return true;
    } else {
        $.messager.show({
            title: commonLang.tip.alert,
            msg: commonLang.tip.checkDataCorrect,
            timeout: 3000,
            showType: 'slide'
        });
        return false;
    }
}

/*function endEditing() {
    if (editIndex == undefined) {
        return true;
    }

    if ($('#cbbTabColumnsDataGrid').datagrid('validateRow', editIndex)) {

        $('#cbbTabColumnsDataGrid').datagrid('endEdit', editIndex);
        var rowData = $('#cbbTabColumnsDataGrid').datagrid('getData').rows[editIndex];
        if (rowData == undefined) {
            return true;
        }
        var colLabel = rowData.COLLABEL;
        if (colLabel == "" || colLabel == undefined) {
            $.messager.show({
                title: '提示',
                msg: "第" + (editIndex + 1) + "行【字段中文名】不能为空！",
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLABEL'
                });
            return false;
        }

        var colName = rowData.COLNAME;
        var regn = /^(?![0-9])\w+$/; // 字段名正则（包含字母数字下划线，不能已数字开头，20位）
        if (colName == "" || colName == undefined || !regn.test(colName)) {
            $.messager.show({
                title: '提示',
                msg: "第" + (editIndex + 1) + "行【字段名】输入非法，请查证！",
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLNAME'
                });
            return false;
        }
        var colType = rowData.COLTYPE; // 字段类型
        var colTypeValue = "";
        if (colType == 'string') {
            colTypeValue = "字符串";
        } else if (colType == 'integer') {
            colTypeValue = "整型";
        } else if (colType == 'date') {
            colTypeValue = "日期时间型";
        } else if (colType == 'float') {
            colTypeValue = "浮点型";
        } else if (colType == 'blob') {
            colTypeValue = "BLOB";
        } else if (colType == 'clob') {
            colTypeValue = "CLOB";
        }
        var colLength = rowData.COLLENGTH; // 长度
        var colDecimal = rowData.COLDECIMAL; // 小数位数

        if (colType == "string" && colLength > 4000) { // 验证长度
            $.messager.show({
                title: '提示',
                msg: "第" + (editIndex + 1) + "行，因为选择的【字段类型】为“" + colTypeValue + "”，因此【长度】的值不能超过4000！",
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLENGTH'
                });
            return false;
        }
        if ((colType == "integer" || colType == "float") && colLength > 16) { // 验证长度
            $.messager.show({
                title: '提示',
                msg: "第" + (editIndex + 1) + "行，因为选择的【字段类型】为“" + colTypeValue + "”，因此【长度】的值不能超过16！",
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLENGTH'
                });
            return false;
        }
        if (colType == "float" && colDecimal > 6) { // 验证小数位数
            $.messager.show({
                title: '提示',
                msg: "第" + (editIndex + 1) + "行，因为选择的【字段类型】为“" + colTypeValue + "”，因此【小数位数】的值不能超过6！",
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLDECIMAL'
                });
            return false;
        }

        if ((colType == "string" || colType == "date" || colType == "clob" || colType == "integer" || colType == "blob") && colDecimal != "" && colDecimal != undefined) { // 验证小数位数
            $.messager.show({
                title: '提示',
                msg: "第" + (editIndex + 1) + "行，因为选择的【字段类型】为“" + colTypeValue + "”，因此【小数位数】的值必须为空！",
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLDECIMAL'
                });
            return false;
        }
        if ((colType == "date" || colType == "clob" || colType == "blob") && colLength != "" && colLength != undefined) { // 验证长度
            $.messager.show({
                title: '提示',
                msg: "第" + (editIndex + 1) + "行，因为选择的【字段类型】为“" + colTypeValue + "”，因此【长度】的值必须为空！",
                timeout: 3000,
                showType: 'slide'
            });
            $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex)
                .datagrid('editCell', {
                    index: editIndex,
                    field: 'COLLENGTH'
                });
            return false;
        }
        return true;
    } else {
        $.messager.show({
            title: '提示',
            msg: "请检查数据是否正确！",
            timeout: 3000,
            showType: 'slide'
        });
        return false;
    }
}
*/

/**
 * 追加行
 */
function append() {
    if (endEditing()) {

        //循环页面数据找出最大order

        $('#cbbTabColumnsDataGrid').datagrid('appendRow', {
            COLTYPE: 'string',
            COLLENGTH: '32',
            isNew: 'Y'
        });
        $('#cbbTabColumnsDataGrid').datagrid('endEdit', editIndex);
        editIndex = $('#cbbTabColumnsDataGrid').datagrid('getRows').length - 1;
        onClickCell(editIndex, "COLLABEL", "");
        // 将小数位数设置为只读
        var editors = $('#cbbTabColumnsDataGrid').datagrid('getEditors',
            editIndex);
        var sfgzEditor2 = editors[4];
        var decimalInput = sfgzEditor2.target; // 得到文本框对象
        decimalInput.numberbox('setValue', "");
        decimalInput.prop('readonly', true); // 设值只读
    }
}



/**
 * 删除所选的行
 * commonLang.tip.alert：提示
 * deleterecord：请选择要删除的记录！
 *deleteconfirm 请确认
 *deleteconfirm1 如此字段在表中已存在数据，那么数据也将会被删除！您确定要删除当前所选的字段？
 *deletesuccess 删除成功！
 *deletefailure 删除失败!
 */
function removeit(remind,deleterecord,deleteconfirm,deleteconfirm1,deletesuccess,deletefailure) {
    var rows = $('#cbbTabColumnsDataGrid').datagrid('getChecked');
    if (rows == "") {
        $.messager.alert(commonLang.tip.alert, deleterecord, "warning");
        return;
    }


    var ids = "";

    $.each(rows, function(index, row) {
        if ("" != row.ID) {
            ids = ids + row.ID + ",";
        }
    });


    var args = {
        sysId: _sysId,
        ids: ids
    };

    $.messager.confirm(deleteconfirm, deleteconfirm1,
        function(b) {
            if (b) {
                // 删除字段
                $.ajax({
                    url: 'platform/im/lantop/basic/ReportManagerController/deletefieldinfosbyid',
                    data: {
                        param: JSON.stringify(args)
                    },

                    type: 'post',
                    dataType: 'json',
                    success: function(result) {
                        if (result.flag == "failure") {
                            $.messager.show({
                                title: commonLang.tip.alert,
                                msg: deletefailure
                            });
                        } else {
                            $.messager.show({
                                title: commonLang.tip.alert,
                                msg: deletesuccess
                            });
                        }
                        reloadDataGrid();
                    }
                });
            }
        });
}


/**
 * 提交改变的记录
 * @param
 * commonLang.tip.alert:提示
 * nosave:没有可保存的记录！
 * notnull:模板名称不能为空！
 * toolarge:模板名称超过长度范围！
 * savesuccess:保存成功！
 * savefailure:保存失败!
 *
 */
function accept(remind,nosave,notnull,toolarge,savesuccess,savefailure) {
    if (endEditing()) {
        if (insertRows == "" && updateRows == "") {
            $.messager.alert(commonLang.tip.alert, nosave, 'warning');
            return false;
        }

        var reportName = $.trim($("#reportName").val());
        if("" == reportName){
            $("#reportName").val('');
            $.messager.alert(commonLang.tip.alert, notnull, 'warning');
            return ;
        }
        if(reportName.length >= 125){
            $.messager.alert(commonLang.tip.alert,
                toolarge, 'warning');
            return;
        }

        // 新增字段
        var insertRows = $("#cbbTabColumnsDataGrid").datagrid('getChanges',
            'inserted');
        var insertRowsArray = [];

        $.each(insertRows, function(index, row) {
            var o = {
                ID: row.ID,
                COL_LABEL: row.COLLABEL,
                COL_NAME: row.COLNAME,
                COL_TYPE: row.COLTYPE,
                COL_LENGTH: row.COLLENGTH,
                COL_DECIMAL: row.COLDECIMAL
            };
            insertRowsArray.push(o);
        });




        // 更新字段
        var updateRows = $("#cbbTabColumnsDataGrid").datagrid('getChanges',
            'updated');


        var updateRowsArray = [];

        $.each(updateRows, function(index, row) {
            var o = {
                ID: row.ID,
                COL_LABEL: row.COLLABEL,
                COL_NAME: row.COLNAME,
                COL_TYPE: row.COLTYPE,
                COL_LENGTH: row.COLLENGTH,
                COL_DECIMAL: row.COLDECIMAL
            };
            updateRowsArray.push(o);
        });


        var args = {
            sysId: _sysId,
            id: templateId,
            text: reportName,
            _parentId: _parentId,
            reportType: "1",
            insertData: insertRowsArray, // 新增数据
            updateData: updateRowsArray // 更新的数据
        };

        $.ajax({
            url: 'platform/im/lantop/basic/ReportManagerController/saveusecustomdatasource',
            data: {
                param: JSON.stringify(args)
            },
            type: 'post',
            dataType: 'json',
            success: function(result) {
                if (result.flag == "failure") {
                    $.messager.show({
                        title: commonLang.tip.alert,
                        msg: savefailure
                    });
                } else {
                    templateId = result.templateId;


                    var dlg = $.messager.show({
                        title: commonLang.tip.alert,
                        msg: savesuccess,
                        timeout: 0
                    });
                    // 使用该方法可以自定义一些关闭事件
                    setTimeout(function() {
                        dlg.window('close');
                        // 保存成功后，关闭页面
                        parent.reportManager.reLoadReportTreeRoot();
                        parent.reportManager.reLoadReportTree();
                        parent.$('#' + _dialogId).dialog('close');
                    }, 3000);


                }
                reloadDataGrid();
            }
        });
    }
}


/**
 * 刷新表格数据
 */
function reloadDataGrid() {
    // 更新数据
    var url = 'platform/im/lantop/basic/ReportManagerController/findfieldinfosbyreportid';

    var args = {
        sysId: _sysId,
        reportId: templateId
    };

    $('#cbbTabColumnsDataGrid').datagrid("options").url = url;
    $("#cbbTabColumnsDataGrid").datagrid('load', {
        param: JSON.stringify(args)
    });
}

/**
 * 转换列类型
 *
 * @param value
 * @param row
 * @param index
 * @returns
 */
function fomaterColType(value, row, index) {
    var type = "";
    if (value == 'string') {
        type = "字符串";
    } else if (value == 'integer') {
        type = "整型";
    } else if (value == 'date') {
        type = "日期时间型";
    } else if (value == 'float') {
        type = "浮点型";
    } else if (value == 'blob') {
        type = "BLOB";
    } else if (value == 'clob') {
        type = "CLOB";
    }
    if (row.colIsDisplay == "N" && row.colIsSys == "Y") {
        return "<font color='red'>" + type + "</font>";
    } else {
        return type;
    }
}


/**
 * 字段类型选择事件
 *
 * @param record
 */
function typeSelect(record) {
    type = record.lookupCode;
}
/**
 * 字段类型选择弹出面板事件
 */
function typeOnHidePanel() {
    if (type != undefined) {
        var length = ""; // 长度
        var lengthEdit = true; // 长度是否可编辑，默认只读
        var decimal = ""; // 小数位数
        var decimalEdit = true; // 小数位数是否可编辑，默认只读
        if (type == "string") {
            length = 30;
            lengthEdit = false;
        } else if (type == "integer") {
            length = 16;
            lengthEdit = false;
        } else if (type == "float") {
            length = 16;
            decimal = 2;
            lengthEdit = false;
            decimalEdit = false;
        }
        // 关闭行编辑
        $('#cbbTabColumnsDataGrid').datagrid('endEdit', editIndex);
        // 打开行编辑
        $('#cbbTabColumnsDataGrid').datagrid('selectRow', editIndex).datagrid(
            'beginEdit', editIndex);
        var editors = $('#cbbTabColumnsDataGrid').datagrid('getEditors',
            editIndex);
        var sfgzEditor1 = editors[3];
        var lengthInput = sfgzEditor1.target; // 得到文本框对象
        lengthInput.numberbox('setValue', length);
        lengthInput.prop('readonly', lengthEdit); // 可编辑
        var sfgzEditor2 = editors[4];
        var decimalInput = sfgzEditor2.target; // 得到文本框对象
        decimalInput.numberbox('setValue', decimal);
        decimalInput.prop('readonly', decimalEdit); // 可编辑
        // 关闭行编辑
        $('#cbbTabColumnsDataGrid').datagrid('endEdit', editIndex);
        // 打开【字段类型】单元格编辑
        onClickCell(editIndex, "COLTYPE", "");
        type = undefined;
    }
}

function fomaterColLabel(value, row, index) {
    if (value == null || value == "null") {
        value = "";
    }
    if (row.colIsDisplay != "Y" && row.colIsSys != "N") {
        return "<font color='red'>" + value + "</font>";
    } else {
        return value;
    }
}

function fomaterColName(value, row, index) {
    if (value == null || value == "null") {
        value = "";
    }
    if (row.colIsDisplay != "Y" && row.colIsSys != "N") {
        return "<font color='red'>" + value + "</font>";
    } else {
        return value;
    }
}

function fomaterColLength(value, row, index) {
    if (value == null || value == "null") {
        value = "";
    }
    if (row.colIsDisplay != "Y" && row.colIsSys != "N") {
        return "<font color='red'>" + value + "</font>";
    } else {
        return value;
    }
}

function fomaterColDecimal(value, row, index) {
    if (value == null || value == "null") {
        value = "";
    }
    if (row.colIsDisplay != "Y" && row.colIsSys != "N") {
        return "<font color='red'>" + value + "</font>";
    } else {
        return value;
    }
}